# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
import logging
# 管道
from datetime import datetime

from scrapydemo.dataSourcu_mysql.Sql_User2 import insertUser

logger =logging.getLogger(__name__)
class ScrapydemoPipeline(object):


    def process_item(self, item, spider):
        if spider.name =='soulewang' :
            logger.info('获取的数据：'+str(dict(item)))
            if item['business_scope']  is not  None:
                item['business_scope'] = item['business_scope'].strip()
            if item['compony_address'] is not None:
                item['compony_address'] = item['compony_address'].strip()
        # 存储数据：
            insertUser(compony_address=item['compony_address'],compony_name=item['compony_name'],sourcce=item['sourcce'],business_scope=item['business_scope'],phone=item['phone'],time=datetime.now().strftime('%Y-%m-%d %H:%M:%S') )
        return item
